#ifndef MILLERRABINTEST_H
#define MILLERRABINTEST_H

#include <QtGlobal>

/**
 * @brief Class to test if a number is prime number using Miller-Rabin algorithmus.
 */
class MillerRabinTest
{
public:
    /**
     * @brief test if a number is prime number
     * @param number    input number
     * @return          result
     *
     * @retval  true    is a prime number
     * @retval  false   is not prime number
     */
    static bool isPrimNumber(quint64 number);

private:
    /**
     * @brief calculate "(a^b) % m" using Montgomery algorithmus.
     *
     * @param a     a
     * @param b     b
     * @param m     m
     * @return      result
     */
    static quint64 runMontgomery(quint64 a, quint64 b, quint64 m);

    /**
     * @brief check if a number is prime number using Miller-Rabin algorithmus.
     * @param a     a
     * @param k     k
     * @param q     q
     * @param n     n
     * @return      result
     *
     * @retval  true    is not a prime number
     * @retval  false   is a prime number
     */
    static bool runMillerRabin(quint64 a, quint64 k, quint64 q, quint64 n);
};

#endif // MILLERRABINTEST_H
